<?php

use Illuminate\Database\Seeder;

use App\Param;

class ParamSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // 生成父级
//        factory(Param::class, 10)->create();
//        $params_id = Param::pluck('id');
//        foreach($params_id as $id) {
//            factory(Param::class, 5)->each(function(Param $param) use ($params_id) {
//
//            })->create();
//        }
        factory(Param::class, 10)->create()->each(function ($param) {
            factory(Param::class, 5)->make()->each(function ($p) use ($param) {
                $param->children()->save($p);
            });
        });
    }
}
